package com.pqtest.api.service;

import com.pqtest.api.dto.TestlibraryDto;
import com.pqtest.api.entity.TestlibraryEntity;
import com.pqtest.api.mapper.TestlibraryMapper;
import com.pqtest.api.utils.DtoEntityTransformer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class TestlibraryService {
    @Autowired
    TestlibraryMapper testlibraryMapper;

    public TestlibraryDto getSimuTest(){
        TestlibraryDto testlibraryDto = new TestlibraryDto();
        DtoEntityTransformer.transalte(testlibraryMapper.getNextExam((new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(new Date())),testlibraryDto);
        return testlibraryDto;
    }
    //报名接口
    public int applySimuTest(int uid,TestlibraryDto testlibraryDto){
        return testlibraryMapper.applySimuTest(uid,testlibraryDto.getId());
    }

    //查询用户是否报名
    public int getIfUserApply(int uid,TestlibraryDto testlibraryDto){
        return testlibraryMapper.getIfUserApply(uid,testlibraryDto.getId());
    }
}
